package com.recruit.server.controller;

import com.recruit.server.common.HeaderInfo;
import com.recruit.server.request.cart.AddCartRequest;
import com.recruit.server.request.cart.ListCartRequest;
import com.recruit.server.request.cart.UpdateCartRequest;
import com.recruit.server.response.cart.AddCartResponse;
import com.recruit.server.response.cart.ListCartResponse;
import com.recruit.server.response.cart.UpdateCartResponse;
import com.recruit.server.service.ICartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    private ICartService iCartService;

    @PostMapping("/list")
    public ListCartResponse list(@Validated @RequestBody ListCartRequest request, HeaderInfo headerInfo) {
        return iCartService.list(request, headerInfo);
    }

    @PostMapping("/add")
    public AddCartResponse add(@Validated @RequestBody AddCartRequest request, HeaderInfo headerInfo) {
        return iCartService.add(request, headerInfo);
    }

    @PostMapping("/update")
    public UpdateCartResponse update(@Validated @RequestBody UpdateCartRequest request, HeaderInfo headerInfo) {
        return iCartService.update(request, headerInfo);
    }
}
